import Vue from "vue";
import Vuex from "vuex";
// import LocalStorage from "../utils/localstorage.js";

Vue.use(Vuex);

const downloadUrl = localStorage.getItem("CANVAS_IMAGE");
// const count = localStorage.getItem("USER_NAME");
const blessing_text = localStorage.getItem("BLESSING_TEXT");
const state = {
  downloadImg: "",
  choicePageCount: 0,
  madeTextCount: 0,
  madeEleCount: 0,
  showWaiting: true
};

const mutations = {
  /**
   * @desc 更新downloadImg
   */
  updateDownloadImg(state, downloadImg) {
    state.downloadImg = downloadImg || "";
  },
  /**
   * @desc 更新username
   */
  updateChoicePageCount(state, choicePageCount) {
    state.choicePageCount = choicePageCount || "";
  },
  /**
   * @desc 更新madeEleCount
   */
  updateMadeEleCount(state, madeEleCount) {
    state.madeEleCount = madeEleCount || "";
  },
  /**
   * @desc 更新madeTextCount
   */
  updateMadeTextCount(state, madeTextCount) {
	  console.log('state.madeTextCount',state.madeTextCount)
    state.madeTextCount = madeTextCount || "";
  },
  /**
   * loading
   * @param {*} state 
   * @param {*} data 
   */
  updateShowWaiting(state, data) {
    state.showWaiting = data
  }
};

const store = new Vuex.Store({
  state,
  mutations
});

export default store;
